package org.mapki;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.RectF;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class LocationOverlay extends Overlay{

	private int lRadius=3;
	private GeoPoint currentLocation;
	
	LocationOverlay() {
		currentLocation = null;
	}
	public void setCurrentLocation(GeoPoint gp){
		this.currentLocation = gp;
	}
	@Override
	public boolean draw (Canvas canvas, MapView mapView, boolean shadow, long when) {
	    Projection projection = mapView.getProjection();
	    Paint paint = new Paint();
	    if(currentLocation != null){
        	Point curLoc = new Point(); 
        	projection.toPixels(currentLocation, curLoc);
        	paint.setColor(Color.BLUE);
        	RectF ovalL=new RectF(curLoc.x - lRadius,curLoc.y - lRadius,
                     curLoc.x + lRadius,curLoc.y + lRadius);
        	canvas.drawOval(ovalL, paint);
        }
	    return super.draw(canvas, mapView, shadow, when);
	}
	
}
